﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:FirstFloor.ModernUI.Windows.Controls;assembly=FirstFloor.ModernUI"
                    xmlns:modernui="clr-namespace:FirstFloor.ModernUI;assembly=FirstFloor.ModernUI"

                    xmlns:conv="clr-namespace:Edi.Core.Converters;assembly=Edi.Core"

                    xmlns:syscmd="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"
                    xmlns:local="clr-namespace:EdiApp.Views.Shell"
                    xmlns:behav="clr-namespace:Edi.Core.Behaviour;assembly=Edi.Core"
                    xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
                    >
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/Button.xaml" />
    <ResourceDictionary Source="/FirstFloor.ModernUI;component/Assets/Converters.xaml" />
  </ResourceDictionary.MergedDictionaries>

  <!-- additional ModernWindow styles -->
  <Style x:Key="EdiSystemButton" TargetType="ButtonBase" BasedOn="{StaticResource SystemButtonBase}">
    <Setter Property="Foreground" Value="{DynamicResource LinkButtonText}"/>
		<Setter Property="Focusable" Value="False"/>
		<Style.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Foreground" Value="{DynamicResource LinkButtonTextHover}"/>
        <Setter Property="Background" Value="{DynamicResource SystemButtonMouseOverBackgroundColor}" />
      </Trigger>
      <Trigger Property="IsPressed" Value="True">
        <Setter Property="Foreground" Value="{DynamicResource LinkButtonTextPressed}" />
      </Trigger>
      <Trigger Property="IsEnabled" Value="false">
        <Setter Property="Foreground" Value="{DynamicResource LinkButtonTextDisabled}" />
      </Trigger>
    </Style.Triggers>
  </Style>

  <!-- empty window style, no backbutton, menu, title links and logo -->
  <Style x:Key="EmptyWindow" TargetType="controls:ModernWindow" BasedOn="{StaticResource {x:Type controls:ModernWindow}}" >
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="controls:ModernWindow">
          <Border x:Name="WindowBorder" Margin="{Binding Source={x:Static shell:SystemParameters2.Current}, Path=WindowNonClientFrameThickness}">
            <Border.Background>
              <SolidColorBrush x:Name="WindowBorderBackground" Color="{DynamicResource WindowBackgroundColor}" />
            </Border.Background>
            <Border.Resources>
              <Storyboard x:Key="BackgroundAnimation">
                <ColorAnimation Storyboard.TargetName="WindowBorderBackground" Storyboard.TargetProperty="Color" To="{DynamicResource WindowBackgroundColor}" Duration="0:0:.6" />
              </Storyboard>
            </Border.Resources>

            <Grid>
              <Border BorderBrush="{DynamicResource WindowBorder}" BorderThickness="1" Background="{DynamicResource WindowBackgroundBrush}">
                <AdornerDecorator>
                  <Grid x:Name="LayoutRoot" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <Grid.ColumnDefinitions>
                      <ColumnDefinition Width="*" />
                      <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>

                    <Grid.RowDefinitions>
                      <RowDefinition Height="Auto" />
                      <RowDefinition Height="*" />
                      <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <Grid Grid.Column="0"
                          >
                      <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                      </Grid.ColumnDefinitions>

                      <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                      </Grid.RowDefinitions>

                      <!-- Window Icon -->
                      <Border Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" Margin="6,0"
                              >
                        <Image HorizontalAlignment="Left"
                               VerticalAlignment="Top"
                               Source="/Edi;component/EdiAppWindowLogo.ico"
                               shell:WindowChrome.IsHitTestVisibleInChrome="True"
                               ToolTip="{Binding ApplicationTitle}"
                               Width="32" Height="32"
                               behav:DoubleClickImageToCommand.DoubleClickItemCommand="{Binding Source={x:Static shell:SystemCommands.CloseWindowCommand}}"
                               behav:DoubleClickImageToCommand.RightClickItemCommand="{Binding Source={x:Static shell:SystemCommands.ShowSystemMenuCommand}}"
                               Visibility="{Binding IsWorkspaceAreaOptimized, Converter={conv:BoolToVisibilityConverter}, ConverterParameter=true}"
                               />
                        <Border.Style>
                          <Style>
                            <Setter Property="Border.Background" Value="Transparent"/>
                            <Style.Triggers>
                                <Trigger Property="Border.IsMouseOver" Value="True">
                                <Setter Property="Border.Background" Value="#20FFFFFF" />
                                </Trigger>
                            </Style.Triggers>
                          </Style>
                        </Border.Style>
                      </Border>

                      <!-- TextBlock Grid.Column="1" Grid.Row="0" Margin="3"
                                 Text="{TemplateBinding Title}" Foreground="Wheat" / -->

                      <!-- Main Menu -->
                      <ContentControl Grid.Column="1"
                                      Grid.Row="1"
                                      VerticalAlignment="Bottom"
                                      VerticalContentAlignment="Bottom"
                                      HorizontalAlignment="Left"
                                      HorizontalContentAlignment="Left"
                                      shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                      Content="{Binding Source={x:Static local:MainWindowViewManager.MainWindowMenu}}"/>
                    </Grid>

                    <!-- window background content -->
                    <!-- ContentControl Grid.RowSpan="2" Content="{TemplateBinding BackgroundContent}" / -->

                    <!-- window system buttons-->
                    <StackPanel Grid.Row="0"
                                Orientation="Horizontal"
                                HorizontalAlignment="Right"
                                VerticalAlignment="Top"
                                Margin="6,0,0,0"
                                syscmd:WindowChrome.IsHitTestVisibleInChrome="True"
                                Visibility="{Binding IsWorkspaceAreaOptimized, Converter={conv:BoolToVisibilityConverter}, ConverterParameter=true}"
                      >
                      <Button Command="{Binding Source={x:Static shell:SystemCommands.MinimizeWindowCommand}}"
                              ToolTip="{x:Static modernui:Resources.Minimize}"
                              Style="{StaticResource EdiSystemButton}">
                        <Button.Content>
                          <Grid Width="32" Height="30"
                                VerticalAlignment="Center" HorizontalAlignment="Center"
                                RenderTransform="1,0,0,1,0,1">
                            <Path Data="M0,6 L8,6 Z" Width="8" Height="7" VerticalAlignment="Center" HorizontalAlignment="Center"
                                  Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}" StrokeThickness="2"  />
                          </Grid>
                        </Button.Content>
                      </Button>
                      <Grid Margin="1,0,1,0">
                        <Button x:Name="Restore"
                                Command="{Binding Source={x:Static shell:SystemCommands.RestoreWindowCommand}}"
                                ToolTip="{x:Static modernui:Resources.Restore}"
                                Style="{StaticResource EdiSystemButton}"
                                Visibility="Collapsed" >
                          <Button.Content>
                            <Grid Width="32" Height="30"
                                  VerticalAlignment="Center" HorizontalAlignment="Center"
                                  UseLayoutRounding="True" RenderTransform="1,0,0,1,.5,.5">
                              <Path Data="M2,0 L8,0 L8,6 M0,3 L6,3 M0,2 L6,2 L6,8 L0,8 Z"
                                    Width="8" Height="8"
                                    VerticalAlignment="Center" HorizontalAlignment="Center"
                                    Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}"
                                    StrokeThickness="1"  />
                            </Grid>
                          </Button.Content>
                        </Button>
                        <Button x:Name="Maximize"
                                Command="{Binding Source={x:Static shell:SystemCommands.MaximizeWindowCommand}}"
                                ToolTip="{x:Static modernui:Resources.Maximize}"
                                Style="{StaticResource EdiSystemButton}" >
                          <Button.Content>
                            <Grid Width="32" Height="30"
                                  VerticalAlignment="Center" HorizontalAlignment="Center">
                              <Path Data="M0,1 L9,1 L9,8 L0,8 Z" Width="9" Height="8" VerticalAlignment="Center" HorizontalAlignment="Center"
                                    Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}"
                                    StrokeThickness="2"  />
                            </Grid>
                          </Button.Content>
                        </Button>
                      </Grid>
                      <Button Command="{Binding Source={x:Static shell:SystemCommands.CloseWindowCommand}}"
                              ToolTip="{x:Static modernui:Resources.Close}"
                              Style="{StaticResource EdiSystemButton}" >
                        <Button.Content>
                          <Grid Width="32" Height="30"
                                HorizontalAlignment="Center" VerticalAlignment="Center"
                                RenderTransform="1,0,0,1,0,1">
                            <Path Data="M0,0 L8,7 M8,0 L0,7 Z" Width="8" Height="7"
                                  VerticalAlignment="Center" HorizontalAlignment="Center"
                                  Stroke="{Binding Foreground, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Button}}"
                                  StrokeThickness="2"  />
                          </Grid>
                        </Button.Content>
                      </Button>
                    </StackPanel>

                    <!-- window content -->
                    <ContentControl Grid.Row="1" Grid.RowSpan="1" Content="{TemplateBinding Content}" />

                    <!-- resize grip -->
                    <Grid Grid.Row="3">
                      <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                      </Grid.ColumnDefinitions>
                      <!-- Main Menu -->
                      <ContentControl Grid.Column="0"
                                      VerticalAlignment="Bottom"
                                      VerticalContentAlignment="Bottom"
                                      HorizontalAlignment="Stretch"
                                      HorizontalContentAlignment="Stretch"
                                      shell:WindowChrome.IsHitTestVisibleInChrome="True"
                                      Content="{Binding Source={x:Static local:MainWindowViewManager.MainWindowStatusBar}}"/>

                      <!-- Path x:Name="ResizeGrip"
                            Grid.Column="1"
                            Visibility="Collapsed" Width="12" Height="12" Margin="1" HorizontalAlignment="Right" 
                            Stroke="{DynamicResource WindowText}"
                            StrokeThickness="1"
                            Stretch="None"
                            Data="F1 M1,10 L3,10 M5,10 L7,10 M9,10 L11,10 M2,9 L2,11 M6,9 L6,11 M10,9 L10,11 M5,6 L7,6 M9,6 L11,6 M6,5 L6,7 M10,5 L10,7 M9,2 L11,2 M10,1 L10,3" / -->
                    </Grid>
                  </Grid>
                </AdornerDecorator>
              </Border>
              <Border BorderBrush="{DynamicResource WindowBorderActive}" BorderThickness="1" Visibility="{Binding IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Converter={StaticResource BooleanToVisibilityConverter}}" />
            </Grid>
          </Border>

          <ControlTemplate.Triggers>
            <Trigger Property="WindowState" Value="Maximized">
              <Setter TargetName="Maximize" Property="Visibility" Value="Collapsed" />
              <Setter TargetName="Restore" Property="Visibility" Value="Visible" />
              <Setter TargetName="LayoutRoot" Property="Margin" Value="7" />
            </Trigger>
            <Trigger Property="WindowState" Value="Normal">
              <Setter TargetName="Maximize" Property="Visibility" Value="Visible" />
              <Setter TargetName="Restore" Property="Visibility" Value="Collapsed" />
            </Trigger>
            <!-- MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="ResizeMode" Value="CanResizeWithGrip" />
                <Condition Property="WindowState" Value="Normal" />
              </MultiTrigger.Conditions>
              <Setter TargetName="ResizeGrip" Property="Visibility" Value="Visible" />
            </MultiTrigger -->
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
</ResourceDictionary>